<div id="admin" style="width: 100%;height: 100%;">

					<div class="panel panel-default">
						<div class="panel-heading">
							Ec参数列表
						</div>

						<div class="navbar-form navbar-left" role="search">
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive" style="height:600px;">
								<table class="table">
									<thead>
										<tr>
											<th style="width: 3%;">#</th>
											<th style="width: 10%;">参数key</th>
											<th style="width: 25%;">参数value</th>
											<th style="width: 10%;">描述</th>
											<th style="width: 10%;">操作</th>
										</tr>
									</thead>
									<tbody id="admin_tbody">
									
									</tbody>
								</table>
							</div>
							<!-- /.table-responsive -->
						</div>
						<!-- /.panel-body -->
					</div>

					 <div style="text-align:right">
	                    <span style="margin-right:30px;">当前是：01页</span>
	                    <ul class="pagination pagination-sm" id="paging" style="vertical-align:middle;">
						<li><a href="#">&laquo;</a></li>
						<li><a href="#">1</a></li>
						<li><a href="#">2</a></li>
						<li><a href="#">3</a></li>
						<li><a href="#">4</a></li>
						<li><a href="#">5</a></li>
						<li><a href="#">&raquo;</a></li>
				       </ul>
                    </div>
					
					
					
					
					<div class='pop' id="pop">
						<div class='box'>
							<div class="modal-header">
									交易记录详情
									<button type="button" onclick="closeWindow();" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									<h4 class="modal-title" id="myModalLabel"></h4>
								</div>
								<div>
								    <div class="form-group pad0-30" align="center">
											<label for="firstname" >参数的key:</label>
											<input type="text" class="form-control" id="paramKey" placeholder="参数的key:"><span id="paramKeyErr" style="color: red"></span>
										</div>
										<div class="form-group pad0-30" align="center">
											<label for="lastname" >参数value:</label>
											<input type="text" class="form-control" id="paramValue" placeholder="参数value:"><span id="paramValueErr" style="color: red"></span>
										</div>
										<div class="form-group pad0-30" align="center">
											<label for="lastname" >描述:</label>
											<input type="text" class="form-control" id="description" placeholder="描述:"><span id="descriptionErr" style="color: red"></span>
										</div>
										<input type="hidden" class="form-control" id="ec_id">
								</div>
								<div class="modal-footer">
									<button id="closeW" type="button" class="btn btn-default" onclick="closeWindow();">关闭</button>
									<button id="closeW" type="button" class="btn btn-default" onclick="update();">确认</button>
								</div>
							</div>
							
						</div>
					</div>
					

<script type="text/javascript">

	//页面加载执行数据渲染	
	$(function(){ 
		ready("","");
	}); 
	
	
	//界面加载方法
	function ready(currentPageNum,totle){
		
		$.ajax({  
		    type:'post',    
		    url:'/Param/findAll.do',  
		    data:null,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	Data_assembly(data);
		    	//footer(data.data.totalPageNum,data.data.currentPageNum);
		    }  
		  });
	}
	
	//数据组装方法
	function Data_assembly(data){
		  var tbody=data.data;
		  var html="";
		  var b=1;
		  for(var i=0;i<tbody.length;i++){
			  html+='<tr>';
			  html+='<td>'+b+'</td>';
			  html+='<td>'+tbody[i].paramKey+'</td>';
			  html+='<td>'+tbody[i].paramValue+'</td>';
			  html+='<td>'+tbody[i].description+'</td>';
			  html+='<td><button type="button"  onclick="updateEc('+"'"+tbody[i].id+"'"+');" class="btn btn-warning">修改</button></td>';
			  html+='</tr>';
			  b++;
		  }
		  
		  $("#admin_tbody").html(html);
	}
	
	
	//修改前查询
	function updateEc(id){
		
		var data={'id':id};
		
		$.ajax({  
		    type:'post',    
		    url:'/Param/findAll.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	  var tbody=data.data;
		    	  $("#paramKey").val("");
		    	  $("#paramValue").val("");
		    	  $("#description").val("");
		    	  $("#paramKey").val(tbody[0].paramKey);
		    	  $("#paramValue").val(tbody[0].paramValue);
		    	  $("#description").val(tbody[0].description);
		    	  $("#ec_id").val(id);
		    	  closeWindow();
		    }  
		  });
	}
	
	//修改
	function update(){
		var paramKey= $("#paramKey").val();
	   	var paramValue=$("#paramValue").val();
	   	var description= $("#description").val();
		var id=$("#ec_id").val();
		var i=0;
	   	if(id==null || id==''){
	   		alert("系统错误");
	   		return;
	   	}
	   	if(paramKey==null || paramKey==''){
	   		$("#paramKeyErr").html("key不能为空");
	   		i=1;
	   	}else{
	   		$("#paramKeyErr").html("");
	   	}
	   	
		if(paramValue==null || paramValue==''){
	   		$("#paramValueErr").html("key不能为空");
	   		i=1;
		}else{
	   		$("#paramValueErr").html("");
	   	}
		
		if(description==null || description==''){
	   		$("#descriptionErr").html("key不能为空");
	   		i=1;
		}else{
	   		$("#descriptionErr").html("");
	   	}
		
		if(i==1){
			return;
		}
		
		var data={'id':id,'paramKey':paramKey,'paramValue':paramValue,'description':description};
		$.ajax({  
		    type:'post',    
		    url:'/Param/updateEc.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	  alert(data.msg);
		    	  ready("","");
		    	  closeWindow();
		    }  
		  });

	}
	
	function closeWindow(){
		$("#pop").fadeToggle();
	}
</script>